function back(url){
	window.location.href = url; 
}
function checkPasswordMsg(passwd){
	var strMsg = "";
	// --- Password Length ---
	if(passwd.length < 8){
		strMsg = strMsg  + language('password_length_check');
	}
	// --- Lower Case ---
	if(!passwd.match(/(.*[a-z])/)){
		strMsg = strMsg  + language('lower_case_check');
	}
	// --- Number ---
	if(!passwd.match(/(.*[0-9])/)){
		strMsg = strMsg  + language('number_check');
	}
	return strMsg;
}
      
function language(id){
    
    var msg =new Array(); 
    msg['password_length_check'] = Drupal.t('Must contain at least 8 characters.<br>');
    msg['lower_case_check'] = Drupal.t('Must contain at least 1 lower case letter [a - z].<br>');
    msg['number_check'] = Drupal.t('Must contain at least 1 number [0 - 9].<br>');
    msg['current_passwd'] = Drupal.t('Please enter Current Password.');
    msg['new_passwd'] = Drupal.t('Please enter New Password.');
    msg['confirm_passwd'] = Drupal.t('Please enter Confirm Password.');
    msg['match_passwd'] = Drupal.t('The password and confirmation do not match.');
    msg['system_forget_passwd_error'] = Drupal.t('Network Problem. Please try again later.');
    msg['system_change_passwd_error'] = Drupal.t('Network Problem. Please try again later.');
    msg['login_id'] = Drupal.t('Please enter your Login ID.');
    msg['email_check'] = Drupal.t('Please enter a valid email address.');
    msg['match_cur_new'] = Drupal.t('Current Password and New Password are same. Please try again.');
    
    if(msg[id]){
        return msg[id];
    }else{
        return '';
    }
}

function clear_form(id){
    jQuery(':input','#'+id).not(':button, :submit, :reset, :hidden').val('');
}
  
function send_change(){

  jQuery(".UserMsg").hide();
  jQuery(".SuccessMsg").hide();
  jQuery(".ReturnMsg.iconAlert").hide();
  jQuery(".ReturnMsg.iconInfo").hide();

  
  var txtCurrentPassword = jQuery('#edit-txtcurrentpassword').val();
  var txtNewPassword = jQuery('#edit-txtnewpassword').val();
  var txtConfirmPassword = jQuery('#edit-txtconfirmpassword').val();
      
      
  if( txtCurrentPassword == ''){
    jQuery(".UserMsg").html(language('current_passwd'));
    jQuery(".UserMsg").slideDown('fast');
    return false;
  }
  if( txtNewPassword == ''){
    jQuery(".UserMsg").html(language('new_passwd'));
    jQuery(".UserMsg").slideDown('fast');
    return false;
  }
      
  var errorMsg = checkPasswordMsg(txtNewPassword);
      
  if(errorMsg  != ""){
    jQuery(".UserMsg").html(errorMsg);
    jQuery(".UserMsg").fadeIn('fast');
      return false;
  }else{
    jQuery(".UserMsg").slideUp('fast');
    jQuery(".UserMsg").html("");
  }
      
      
  if( txtConfirmPassword == ''){
    jQuery(".UserMsg").html(language('confirm_passwd'));
    jQuery(".UserMsg").slideDown('fast');
    return false;
  }
  if(txtCurrentPassword == txtNewPassword){
    jQuery(".UserMsg").html(language('match_cur_new'));
    jQuery(".UserMsg").slideDown('fast');
    return false;
  }
  if(txtNewPassword != txtConfirmPassword){
    jQuery(".UserMsg").html(language('match_passwd'));
    jQuery(".UserMsg").slideDown('fast');
    return false;
  }
  document.getElementById("usermanage-ajax-progress_throbber").style.display = 'block';

  
   jQuery.post('./getxml',{"type":"2","curpasswd":txtCurrentPassword,"newpasswd":txtNewPassword},function(n){
      var json = eval('(' + n + ')');
      if(json.statusCode == 200){
          jQuery(".SuccessMsg").show();
          clear_form('usermanage-change');
      }else{
          if( json.statusMessage ){
            jQuery(".UserMsg.iconAlert").html(json.statusMessage);
            jQuery(".UserMsg.iconAlert").slideDown('fast');
          }else{
            jQuery(".UserMsg.iconAlert").html(language('system_change_passwd_error'));
            jQuery(".UserMsg.iconAlert").slideDown('fast');
          }
      }
      document.getElementById("usermanage-ajax-progress_throbber").style.display = 'none';
     
    });
    
}


function send_forget(){

  jQuery(".UserIDMsg").hide();
  jQuery(".SuccessMsg").hide();
  jQuery(".ReturnMsg.iconAlert").hide();
  jQuery(".ReturnMsg.iconInfo").hide();

      
  var txtUserID = jQuery('#edit-txtuserid').val();
  txtUserID = jQuery.trim(txtUserID);
    
  if( txtUserID == ''){
    jQuery(".UserIDMsg").html(language('login_id'));
    jQuery(".UserIDMsg").slideDown('fast');
    return false;
  }
  
  /*if(!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(txtUserID)){
    jQuery(".UserIDMsg").html(language('email_check'));
    jQuery(".UserIDMsg").slideDown('fast');
    return false;
  }*/
    
  
  document.getElementById("usermanage-ajax-progress_throbber").style.display = 'block';
  
   jQuery.post('./getxml',{"type":"1","uid":txtUserID},function(n){
      var json = eval('(' + n + ')');  
      if(json.statusCode == 200){
          jQuery(".SuccessMsg").show();
          clear_form('usermanage-forget');
      }else{
            jQuery(".ReturnMsg.iconAlert").html(language('system_forget_passwd_error'));
            jQuery(".ReturnMsg.iconAlert").slideDown('fast');
      }
      document.getElementById("usermanage-ajax-progress_throbber").style.display = 'none';
    });
    
}

jQuery(document).ready(function(){
    jQuery("#edit-txtuserid").keydown(function(event){ 
        if(event.keyCode==13){return false;}; 
    });
});
